<aside class="main-sidebar" id="app">
    <!-- sidebar: style can be found in sidebar.less -->
    <section class="sidebar">
        <!-- Sidebar user panel -->
        <div class="user-panel">
            <div class="pull-left image">
                <img src="/img/user2-160x160.jpg" class="img-circle" alt="User Image">
            </div>
            <div class="pull-left info">
                <p> 用户名称：{{msg}}</p>
                <a href="#" @click="logout">退出</a>
            </div>
        </div>

        <!-- sidebar menu: : style can be found in sidebar.less -->
        <ul class="sidebar-menu">
            <li class="header">菜单</li>

            <li class="treeview">
                <a href="#">
                    <i class="fa fa-cube"></i> <span>系统管理</span>
                    <span class="pull-right-container">
                     <i class="fa fa-angle-left pull-right"></i>
                 </span>
                </a>
                <ul class="treeview-menu">
                    <li id="sys-user">
                        <a href="/pages/user/user-list.html" onclick="setSidebarActive(this)" target="iframe">
                            <i class="fa fa-circle-o"></i>用户管理
                        </a>
                    </li>
                    <li>
                        <a href="/pages/role/role-list.html" onclick="setSidebarActive(this)" target="iframe">
                            <i class="fa fa-circle-o"></i>角色管理
                        </a>
                    </li>
                </ul>
            </li>

        </ul>

    </section>
    <!-- /.sidebar -->
</aside>
<script src="/js/vue.js"></script>
<script src="/js/axios.js"></script>
<script>
    new Vue({
        el:"#app",
        data:{
            user:{},
            msg:''
        },
        methods:{
            // 查询登陆用户
            loginUser(){
                axios.get("/loginUser").then(resp=>{
                    let resultInfo = resp.data;
                    if (resultInfo.success){
                        this.msg = resultInfo.message;
                    }
                })
            },
            logout(){
                axios.get('/logout').then(resp=>{
                    if (resp.status == 200) {
                        location.href = '/login.html';
                    }
                })
            }
        },
        // 创建vue对象之后执行
        created(){
            this.loginUser();
        }
    });
</script>